package entity.cwe;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xym
 * @date 2020/7/15
 */
public class Weakness {
    private Integer id;
    private String name;
    private String description;
    /**
     * 使用字符串"关系-id"来表示，比如"ChildOf-156"
     */
    private List<String> relatedWeakness;
    /**
     * 缺陷的别名
     */
    private List<String> alternateTerms;
    /**
     * 缺陷的引入时机，表明该缺陷属于哪个阶段。
     * 常见的阶段有设计阶段、实现阶段等
     */
    private List<String> modesOfIntroduction;
    private String likelihoodOfExploit;
    private List<String> commonConsequences;
    private List<DetectionMethod> detectionMethods;
    private List<String> mitigations;

    public Weakness() {
        this.relatedWeakness = new ArrayList<>();
        this.alternateTerms = new ArrayList<>();
        this.modesOfIntroduction = new ArrayList<>();
        this.commonConsequences = new ArrayList<>();
        this.detectionMethods = new ArrayList<>();
        this.mitigations = new ArrayList<>();
    }

    public void addRelatedWeakness(String weakness) {
        this.relatedWeakness.add(weakness);
    }

    public void addAlternateTerm(String alternateTerms) {
        this.alternateTerms.add(alternateTerms);
    }

    public void addModesOfIntroduction(String modesOfIntroduction) {
        this.modesOfIntroduction.add(modesOfIntroduction);
    }

    public void addCommonConsequences(String commonConsequences) {
        this.commonConsequences.add(commonConsequences);
    }

    public void addDetectionMethods(DetectionMethod detectionMethod) {
        this.detectionMethods.add(detectionMethod);
    }

    public void addMitigation(String mitigation) {
        this.mitigations.add(mitigation);
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public List<String> getRelatedWeakness() {
        return relatedWeakness;
    }

    public List<String> getAlternateTerms() {
        return alternateTerms;
    }

    public List<String> getModesOfIntroduction() {
        return modesOfIntroduction;
    }

    public String getLikelihoodOfExploit() {
        return likelihoodOfExploit;
    }

    public List<String> getCommonConsequences() {
        return commonConsequences;
    }

    public List<DetectionMethod> getDetectionMethods() {
        return detectionMethods;
    }

    public List<String> getMitigations() {
        return mitigations;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setLikelihoodOfExploit(String likelihoodOfExploit) {
        this.likelihoodOfExploit = likelihoodOfExploit;
    }

    @Override
    public String toString() {
        return "Weakness{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", relatedWeakness=" + relatedWeakness +
                ", alternateTerms=" + alternateTerms +
                ", modesOfIntroduction=" + modesOfIntroduction +
                ", likelihoodOfExploit='" + likelihoodOfExploit + '\'' +
                ", commonConsequences=" + commonConsequences +
                ", detectionMethods=" + detectionMethods +
                ", mitigations=" + mitigations +
                '}';
    }
}

